'use strict';

module.exports = function (mongoose, Schema) {

    let schema = new Schema({
        iCode: {
            type: String,
            unique: true,
            required: true,
        },
        eCode: String,
        name: String,
        pinyin: String,     //汉语全拼
        pinyinF: String,    //汉语首字母
        desc: String,
        descTime: Date,
        stockHolder: Object,//Hbbh:环比变化,Gdzhs:股东总户数,Hbzj:环比增减,Rjcg:人均持股
        marketDate: Date,
    }, {collection: 'stock', timestamps: true});

    schema.index({'stockHolder.Hbbh': 1});

    schema.set('toObject', {virtuals: true});
    schema.set('toJSON', {virtuals: true});

    return mongoose.model('Stock', schema);
};

